<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>班级添加</title>

    <link type="text/css" rel="stylesheet" href="/static/js/layui-v2.5.7/layui/css/layui.css">
    <script type="text/javascript" src="/static/js/layui-v2.5.7/layui/layui.js"></script>
    <script type="text/javascript" src="/static/js/myJs.js"></script>

    <script>
        layui.use(['form'], function () {
            var form = layui.form;
        })
    </script>
</head>
<body>
<a href="SelectClasses" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-primary" title="返回上一页">
    <i class="layui-icon">&#xe65a;</i>
</a>

<form class="layui-form" >
    <div class="layui-form-item">
        <label class="layui-form-label" for="name">班级名字</label>
        <div class="layui-input-inline">
            <input class="layui-input" type="text" name="name" id="name"
                   placeholder="请输入班级名字" autocomplete="off" required>
        </div>
        <button type="button" class="layui-btn" onclick="add()">确认</button>

    </div>


</form>

<!--<script type="text/javascript" src="http://owner.liuheng.com/static/js/jQuery-2.2.0.min.js"></script>-->
<!--action="InsertClasses" method="post"-->
<script>
    $(document).ready(function () {


        $("#name").focusout(function () {

            $.ajax({
                dataType:"json",
                url:"/studentLayer/Classes/checkName",
                data:{"name":$("#name").val()},
                type:"POST",
                success:function (data) {
                    window.layer.msg(data.status);
                }
            })

        });


        function add() {
            $.ajax({
                dataType:"json",
                url :"/studentLayer/Classes/InsertClasses",
                method:"POST",
                data:{"name":$("#name").val()},
                success:function (data) {
                    if(data.code > 0){
                        layer.msg(data.msg,{time:"2000"});
                    }else {
                        layer.msg(data.msg,{time:"2000"},function () {
                            window.location.href = "/studentLayer/Classes/SelectClasses";
                        });
                    }
                }
            })
        }

    })



</script>






</body>
</html>